﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A2DFramework.Diagnostics
{
    public class Timing
    {
        private TimeSpan start;
        private TimeSpan duration;

        public void Start()
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();

            start = Process.GetCurrentProcess().Threads[0].UserProcessorTime;
        }

        public void Stop()
        {
            duration = Process.GetCurrentProcess().Threads[0].UserProcessorTime.Subtract(start);
        }

        public TimeSpan Duration
        {
            get
            {
                return this.duration;
            }
        }
    }
}
